package org.smartblog.core;

import java.net.UnknownHostException;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.reflect.MethodUtils;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;


/**
 * Create Date:2013-12-5
 * 
 * @author wanghx
 */
public class Test {

	public static void main(String[] args) {
		String phone = "/{dasdads}/{111}";
		String paramRegx = "\\{.*?\\}";
		String regx = "\\{(.*?):(.*?)\\}";
		Pattern paramPattern = Pattern.compile(paramRegx);
		Matcher paramMatcher = paramPattern.matcher(phone);

		

		String param = null;
		String regxStr = null;

		while (paramMatcher.find()) {
			param = paramMatcher.group();
			System.out.println("param --> " + param);
			phone = StringUtils.replaceOnce(phone, param, "[a-z0-9]*");
			
			System.out.println(phone);
		}

		
		String str = "/123/33";
		Pattern regxPattern = Pattern.compile("^" + phone + "$");
		Matcher regxMatcher = regxPattern.matcher(str);
		System.out.println(regxMatcher.matches());
		
		System.out.println(str.replaceFirst("[0-9]*", "z"));
		
//		MongoClient mongoClient = null;
//		try {
//			mongoClient = new MongoClient( "localhost" , 27017 );
//			
//			DB db = mongoClient.getDB( "test" );
//			DBCollection collection = db.getCollection("test");
//			DBObject myDoc = collection.findOne();
//			BasicDBObject dbobject = null;
//
//			System.out.println(myDoc);
//			
//		} catch (UnknownHostException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}finally{
//			if(mongoClient != null)
//				mongoClient.close();
//		}
		
		
	}
}
